package org.nlp.algo.classifier;

import java.io.File;
import java.io.IOException;

import libsvm.svm_model;

import org.apache.commons.io.FileUtils;
import org.nlp.algo.classifier.svm.SVMLibClassifier;

public class TestSVMClassifier {
	// 训练语料文件夹
	private static String corpusPath = "resource/corpus";
	
	private static File trainDir = new File(corpusPath+"/train");
	
	//模型文件名
	private static String modelFile = "resource/model/svmlib.model";
		
	public static void main(String[] args) throws IOException {
		
		//暂时训练与
		SVMLibClassifier slc = new SVMLibClassifier(new File(corpusPath+"/SVMClassList.txt"));
	
		svm_model model = slc.train(trainDir);
		
		slc.saveModel(modelFile, model);
		String text = FileUtils.readFileToString(new File("./testsvm.txt"));
		String cls = slc.classifier("./svmlib.model", text);
		System.out.println(cls);								
	}
}
